package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.GuestMapper;
import com.ruoyi.system.domain.Guest;
import com.ruoyi.system.service.IGuestService;
import com.ruoyi.common.core.text.Convert;

/**
 * 客人信息Service业务层处理
 * 
 * @author 华馨悦
 * @date 2025-01-24
 */
@Service
public class GuestServiceImpl extends ServiceImpl<GuestMapper,Guest> implements IGuestService

{
    @Autowired
    private GuestMapper guestMapper;

    /**
     * 查询客人信息
     * 
     * @param id 客人信息主键
     * @return 客人信息
     */
    @Override
    public Guest selectGuestById(Long id)
    {
        return guestMapper.selectGuestById(id);
    }

    /**
     * 查询客人信息列表
     * 
     * @param guest 客人信息
     * @return 客人信息
     */
    @Override
    public List<Guest> selectGuestList(Guest guest)
    {
        return guestMapper.selectGuestList(guest);
    }

    /**
     * 新增客人信息
     * 
     * @param guest 客人信息
     * @return 结果
     */
    @Override
    public int insertGuest(Guest guest)
    {
        return guestMapper.insertGuest(guest);
    }

    /**
     * 修改客人信息
     * 
     * @param guest 客人信息
     * @return 结果
     */
    @Override
    public int updateGuest(Guest guest)
    {
        return guestMapper.updateGuest(guest);
    }

    /**
     * 批量删除客人信息
     * 
     * @param ids 需要删除的客人信息主键
     * @return 结果
     */
    @Override
    public int deleteGuestByIds(String ids)
    {
        return guestMapper.deleteGuestByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除客人信息
     *
     * @param ids 需要软删除的客人信息主键
     * @return 结果
     */
    @Override
    public int softDeleteGuestByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            Guest guest = guestMapper.selectGuestById(Long.valueOf(s));
            guest.setIsDelete(1);
            int i = guestMapper.updateGuest(guest);
            count = count + i;
        }
        return count;
    }

    /**
     * 删除客人信息信息
     * 
     * @param id 客人信息主键
     * @return 结果
     */
    @Override
    public int deleteGuestById(Long id)
    {
        return guestMapper.deleteGuestById(id);
    }
}
